package com.zhaojiadi.spring.bean.definition;

import com.zhaojiadi.thinking.in.spring.ioc.overview.domain.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Bean 别名示例
 */
public class BeanAliasDemo {
    public static void main(String[] args) {
        //配置xml配置文件
        //启动Spring应用上下文
        BeanFactory beanFactory = new ClassPathXmlApplicationContext("classpath:/META-INF/bean-definitions-context.xml");
        //通过别名xiaomage获取曾用名yser的bean
        User user = beanFactory.getBean("user", User.class);
        User xiaomage = beanFactory.getBean("xiaomage-user", User.class);
        System.out.println("xiaomage-user是否与user Bean相同:"+(user==xiaomage));
    }


}
